fix(operator): unblock sweep when schema migration is timeout-skipped#64
Merged
Conversation
The post-switchover sweep deletes Active restores other than the
currentRestore once the switchover grace period has elapsed. The gate
that allows it to run was an allow-list of "migration is done" phases:
`None`, `complete`, `partial`. When the `timeout-skipped` phase was
added the gate was not updated, so a replica whose last migration
timed out kept treating the migration as in-flight forever. The sweep
never ran; stale Active restores accumulated; once three Actives
existed the MAX_RESTORES_PER_REPLICA guardrail blocked new restores
too. The replica was "Ready" but functionally frozen on a stale
snapshot until manual intervention.
Re-code the gate as "migration is not actively in flight" — i.e. not
`Some("active")` — rather than enumerating every terminal phase. The
set of phases has grown over time and adding new ones shouldn't risk
silently re-introducing this class of deadlock. Extract the predicate
as `persistent_schemas_migration_settled` so it has one definition
and can be tested directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖
Summary
The post-switchover sweep — the bit that deletes the prior Active restore once the grace period has elapsed — was gated on a "migration is done" check that hadn't been updated when the `timeout-skipped` phase was added. So a replica whose last migration timed out kept treating the migration as in-flight forever, the sweep never ran, stale Active restores accumulated, and once three were live the `MAX_RESTORES_PER_REPLICA` guardrail blocked new restores too. Effect: the replica was "Ready" but functionally frozen on a stale snapshot until manual intervention.
Fix
Re-code the gate as "migration is not actively in flight" (`phase != Some("active")`) rather than enumerating every terminal phase. The set of phases has grown — `complete`, `partial`, `failed: `, now `timeout-skipped` — and the previous allow-list shape meant each new phase risked silently re-introducing this class of deadlock.
Shape
Tests
Four new unit tests:
Recovery
Existing replicas in the field with `schemaMigrationPhase: "timeout-skipped"` will recover automatically on first reconcile after deploy: the sweep runs, deletes the stale Actives, clears the phase, and the next scheduled restore can proceed. No manual cleanup required.